"use strict";
const tool = require("../utils/tool");
const Constants = require("../config");
const _ = require("lodash");
const request = require("request-promise-native");
const moment = require("moment");
const mongoose = require("mongoose");
const cardsApp = require("./cards_app");

const apiBase = {
  "status":0,
  "message":"everything is ok"
}

async function getDot(req, res) {
  const client = tool.getResponseFunc(res);
  let result = {};
  try {
    req.query.type = req.params.type;
    req.query.resData = true;
    const cardResult = await cardsApp.getCardByUsername(req, res);
    let cardDataLength = 0;
    if(cardResult.status == 0){
      cardDataLength = cardResult.result.items.length || 0;
    }
    result = {
      ...apiBase,
      tip: {
        notify_type: cardDataLength > 0 ? 'digit' : 'nothing',
        num: cardDataLength
      }
    }
    res.json(result);
  } catch (e) {
    client.fail(e);
  }
}

module.exports = {
  getDot
}
